
#include "debug.h"
#include "cmsis_os.h"


/*********************************************************************
 * @fn      GPIO_Toggle_INIT
 *
 * @brief   Initializes GPIOA.0/1
 *
 * @return  none
 */
void GPIO_Toggle_INIT(void)
{
  GPIO_InitTypeDef  GPIO_InitStructure={0};

  RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE);
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0|GPIO_Pin_1;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
  GPIO_Init(GPIOA, &GPIO_InitStructure);
	
	RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC,ENABLE);
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
  GPIO_Init(GPIOC, &GPIO_InitStructure);
}

extern void application_entry(void *arg);
osThreadDef(application_entry, osPriorityNormal, 1, 1024);

/*********************************************************************
 * @fn      main
 *
 * @brief   Main program.
 *
 * @return  none
 */
int main(void)
{
	SystemCoreClockUpdate();

	USART_Printf_Init(115200);
	GPIO_Toggle_INIT();
	GPIO_ResetBits(GPIOC,GPIO_Pin_13);

	printf("\n\n === Started ===\n");
	printf("SystemClk:%d\r\n",SystemCoreClock);
	printf( "ChipID:%08x\r\n", DBGMCU_GetCHIPID() );
	printf("Welcome to TencentOS tiny(%s)\r\n", TOS_VERSION);
	

	osKernelInitialize(); //TOS Tiny kernel initialize
	osThreadCreate(osThread(application_entry),NULL); // Kernel test
  osKernelStart();//Start TOS Tiny

	printf("should not run at here!\r\n");

	while(1)
	{
	
	}
}


